const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
const path = require('path');
const exclusionList = require('metro-config/src/defaults/exclusionList');

/**
 * Metro configuration
 * https://reactnative.dev/docs/metro
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {
  watchFolders: [path.resolve(__dirname)],
  resolver: {
    blockList: exclusionList([
      // Ignore ios/Pods directory to prevent "too many open files" error
      /ios\/Pods\/.*/,
      /ios\/build\/.*/,
      /ios\/gems\/.*/,
      /node_modules\/.*\/node_modules\/react-native\/.*/,
    ]),
  },
  watchman: {
    // Reduce memory usage
    'ignore-dirs': ['ios/Pods', 'ios/build', 'ios/gems', 'node_modules'],
  },
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
